//
//  DetailNoticeViewController.m
//  Contractor
//
//  Created by 金鑫 on 16/5/17.
//  Copyright © 2016年 star j. All rights reserved.
//

#import "DetailNoticeViewController.h"
#import "CONST.h"

@interface DetailNoticeViewController ()

@end

@implementation DetailNoticeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor] ;
    self.extendedLayoutIncludesOpaqueBars = NO;
    self.edgesForExtendedLayout = UIRectEdgeBottom | UIRectEdgeLeft | UIRectEdgeRight;
    self.view.backgroundColor = [UIColor whiteColor] ;
    [self createtextView] ;
}

- (void)createtextView
{
    UILabel *titleLabel = [self creatlabel:20.0f color:[UIColor blackColor]] ;
    titleLabel.text = self.model.msgtitle ;
    CGSize titleLength = [self lengthwithLabel:titleLabel withsize:20.0f] ;
    titleLabel.frame = CGRectMake(10, 16, titleLength.width, 22.0f) ;
    [self.view addSubview:titleLabel] ;
    
    
    NSString *timeStamp2 = self.model.inputdatetime;
    long long int date1 = (long long int)[timeStamp2 intValue];
    NSDate *date2 = [NSDate dateWithTimeIntervalSince1970:date1];
    NSString *datestr = [NSString stringWithFormat:@"%@",date2] ;
    datestr = [datestr substringToIndex:19] ;
   
    UILabel *timeLabel = [self creatlabel:18.0f color:[UIColor grayColor]] ;
    timeLabel.text = datestr ;
    timeLabel.frame = CGRectMake(0, 17, __kScreenWidth-10, 20.0f) ;
    timeLabel.textAlignment = NSTextAlignmentRight ;
    [self.view addSubview:timeLabel] ;
    
    UIImageView *lineView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 54, __kScreenWidth, 0.5) ];
    [lineView setImage:[UIImage imageNamed:@"layout_small_line_bg.png"]] ;
    [self.view addSubview:lineView] ;
    
    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 60, __kScreenWidth, self.view.frame.size.height - 60)] ;
    NSString *textStr = self.model.msg ;
    textView.text = textStr ;
    textView.font = [UIFont fontWithName:@"AvenirLTStd-Light" size:16.0f] ;
    textView.showsVerticalScrollIndicator = NO ;
    textView.editable = NO ;
    textView.selectable = NO ;
    //    [textView addSubview:title] ;
    [self.view addSubview:textView] ;
}

//创建label
- (UILabel *)creatlabel:(CGFloat) size color:(UIColor *)color
{
    UILabel *label = [[UILabel alloc] init] ;
    label.font = [UIFont fontWithName:@"AvenirLTStd-Light" size:size] ;
    label.backgroundColor = [UIColor clearColor] ;
    label.textAlignment = NSTextAlignmentCenter ;
    label.textColor = color ;
    return label ;
}

- (CGSize)lengthwithLabel:(UILabel *)lable withsize:(CGFloat) size
{
    NSDictionary *attribute1 = @{NSFontAttributeName: [UIFont fontWithName:@"AvenirLTStd-Light" size:size]};
    CGSize DescSize = [lable.text boundingRectWithSize:CGSizeMake(MAXFLOAT, size) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute1 context:nil].size;
    return DescSize ;
}

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = NO ;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
